﻿/*using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System.Diagnostics;
using System.ComponentModel;
using BEPUphysics.Entities;

namespace The_LarX
{
    public class BepuCarPlayer : Component
    {
        /// <summary>
        /// O Actor que estamos usando
        /// </summary>
#if WINDOWS
        [Category("Geral")]
        [Description("O Actor  que estamos usando")]
#endif
        public Actor Body
        {
            get { return actor; }
            set { actor = value; }
        }
        protected Actor actor;
        public Actor Wheel1Actor
        {
            get;
            set;
        }
        public Actor Wheel2Actor
        {
            get;
            set;
        }
        public Actor Wheel3Actor
        {
            get;
            set;
        }
        public Actor Wheel4Actor
        -{
            get;
            set;
        }

        protected RenderType renderType;
        /// <summary>
        /// O renderType utilizado
        /// </summary>
        public RenderType RenderType
        {
            get { return renderType; }
            set
            {
                if (renderType != value)
                {
                    Model wheel1 = Wheel1Actor.Model;
                    Model wheel2 = Wheel2Actor.Model;
                    Model wheel3 = Wheel3Actor.Model;
                    Model wheel4 = Wheel4Actor.Model;
                    Model body = Body.Model;
                    Engine.Render.RemapModel(ref wheel1, value);
                    Engine.Render.RemapModel(ref wheel2, value);
                    Engine.Render.RemapModel(ref wheel3, value);
                    Engine.Render.RemapModel(ref wheel4, value);
                    Engine.Render.RemapModel(ref body, value);
                }
                renderType = value;
            }
        }

        public BepuEntity_Car Car;

        public BepuCarPlayer(BepuEntity_Car Entity, Actor Body, Actor Wheel, GameScreen Screen)
            : base(Screen)
        {
            this.Car = Entity;
            this.Car.Actor = Body;

            //Wheel1
            this.Wheel1Actor = Wheel;
            this.Wheel1Actor.ComponentParent = this;
            this.Wheel1Actor.Entity = Car;
            this.Wheel1Actor.Position = Car.Wheel[0].Suspension.LocalAttachmentPoint;

            //Wheel2
            this.Wheel2Actor = new Actor(Wheel1Actor.ModelName);
            this.Wheel2Actor.ComponentParent = this;
            this.Wheel2Actor.Entity = Car;
            this.Wheel2Actor.Position = Car.Wheel[0].Suspension.LocalAttachmentPoint;
            
            //Wheel3
            this.Wheel3Actor = new Actor(Wheel1Actor.ModelName);
            this.Wheel3Actor.ComponentParent = this;
            this.Wheel3Actor.Entity = Car;
            this.Wheel3Actor.Position = Car.Wheel[0].Suspension.LocalAttachmentPoint;

            //Wheel4
            this.Wheel4Actor = new Actor(Wheel1Actor.ModelName);
            this.Wheel4Actor.ComponentParent = this;
            this.Wheel4Actor.Entity = Car;
            this.Wheel4Actor.Position = Car.Wheel[0].Suspension.LocalAttachmentPoint;

            //Body
            this.Body = Body;
            this.Body.ComponentParent = this;
            this.Body.Entity = Car;

            this.RenderType = Engine.Render.RenderType;

            Wheel1Actor.Position = Body.Position + Car.Vehicle.Wheels[0].Suspension.LocalAttachmentPoint;
            Wheel2Actor.Position = Body.Position + Car.Vehicle.Wheels[1].Suspension.LocalAttachmentPoint;
            Wheel3Actor.Position = Body.Position + Car.Vehicle.Wheels[2].Suspension.LocalAttachmentPoint;
            Wheel4Actor.Position = Body.Position + Car.Vehicle.Wheels[3].Suspension.LocalAttachmentPoint;
        }
        public BepuCarPlayer()
            : base()
        {
        }

        public override void DisableComponent()
        {
            this.Wheel1Actor.Disable();
            this.Wheel2Actor.Disable();
            this.Wheel3Actor.Disable();
            this.Wheel4Actor.Disable();
            this.Body.Disable();

            base.DisableComponent();
        }

        public override void Update()
        {
            Wheel1Actor.Update();
            Wheel2Actor.Update();
            Wheel3Actor.Update();
            Wheel4Actor.Update();
            Body.Update();
            Car.Update();

            if (Engine.PlayMode)
            {
                Body.Position = Car.Entity.CenterPosition;
                Body.Scale = Car.Scale;
                Body.VectorRotation = Car.Rotation;

                Wheel1Actor.Position = Car.Vehicle.Wheels[0].Suspension.WorldAttachmentPoint;
                Wheel1Actor.VectorRotation = Car.Wheel1Rotation;

                Wheel2Actor.Position = Car.Vehicle.Wheels[1].Suspension.WorldAttachmentPoint;
                Wheel2Actor.VectorRotation = Car.Wheel2Rotation;

                Wheel3Actor.Position = Car.Vehicle.Wheels[2].Suspension.WorldAttachmentPoint;
                Wheel3Actor.VectorRotation = Car.Wheel3Rotation;

                Wheel4Actor.Position = Car.Vehicle.Wheels[3].Suspension.WorldAttachmentPoint;
                Wheel4Actor.VectorRotation = Car.Wheel4Rotation;
            }
            else
            {
                Car.Entity.CenterPosition = Body.Position;
                Car.Entity.OrientationMatrix = Body.RotationMatrix;
                Car.Scale = Body.Scale;
                Car.Entity.LinearVelocity = Vector3.Zero;
                Car.Entity.AngularVelocity = Vector3.Zero;

                Car.Vehicle.Wheels[0].Suspension.WorldAttachmentPoint = Wheel1Actor.Position;
                Car.Vehicle.Wheels[1].Suspension.WorldAttachmentPoint = Wheel2Actor.Position;
                Car.Vehicle.Wheels[2].Suspension.WorldAttachmentPoint = Wheel3Actor.Position;
                Car.Vehicle.Wheels[3].Suspension.WorldAttachmentPoint = Wheel4Actor.Position;
            }

            base.Update();
        }
        public override void Draw()
        {
            // Manda o Actor para o sistema de Renderização
            if (Engine.Services.ContainsService(typeof(Camera3D)))
            {
                Engine.Render.RenderActor(Body, Engine.Services.GetService<Camera3D>());
                Engine.Render.RenderActor(Wheel1Actor, Engine.Services.GetService<Camera3D>());
                Engine.Render.RenderActor(Wheel2Actor, Engine.Services.GetService<Camera3D>());
                Engine.Render.RenderActor(Wheel3Actor, Engine.Services.GetService<Camera3D>());
                Engine.Render.RenderActor(Wheel4Actor, Engine.Services.GetService<Camera3D>());
            }
            // E chama o método Draw dele...
            Body.Draw();
            Wheel1Actor.Draw();
            Wheel2Actor.Draw();
            Wheel3Actor.Draw();
            Wheel4Actor.Draw();

            base.Draw();
        }

        public override string ToString()
        {
            return Body.Name + "Player";
        }

        public override void SerializeData()
        {
            base.SerializeData();

            //Actor.SerializeData(this.Data);
            //Entity.SerializeData(this.Data);

            // Serializa o Tipo do Actor
            //Data.AddData("ActorPlayer.Actor", this.Actor.GetType().ToString());
            //.AddData("bEPUActorPlayer.Entity", this.Entity.GetType().ToString());
        }
        public override void DeserializeData()
        {
            base.DeserializeData();

            /*Type ActorType = Type.GetType(Data.GetData<string>("ActorPlayer.Actor"));
            Actor Object = (Actor)System.Activator.CreateInstance(ActorType);
            this.Actor = Object;
            Actor.DeserializeData(Data);
            this.Actor.ComponentParent = this;

            Type EntityType = Type.GetType(Data.GetData<string>("bEPUActorPlayer.Entity"));
            BepuEntity EntityObject = (BepuEntity)System.Activator.CreateInstance(EntityType);
            this.Entity = EntityObject;
            this.Entity.DeserializeData(Data);

            this.Actor.Parent = this;
        }

        public override void SetToInitialState()
        {
            base.SetToInitialState();

            Body.SetToInitialState();
        }
    }
}*/